#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>

#include <cmocka.h>
#include "../include/mymath.h"

// test add function
static void test_add(void **state)
{
    int i;
    for (i = -10; i < 10; i++)
    {
        assert_int_equal(add(i, i), i+i);
    }
}

static void test_sub(void ** state)
{
    int i;
    for (i = -10; i < 10; i++)
    {
        assert_int_equal(sub(i, i), i-i);
    }
}

static void test_div(void **state)
{
    int i;
    for (i = -10; i < 10; i++)
    {
        assert_int_equal(div(i, i), i/i);
    }
}

static void test_mul(void **state)
{
    int i;
    for (i = -10; i < 10; i++)
    {
        assert_int_equal(mul(i, i), i*i);
    }
}

int main(int argc, char const *argv[])
{
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(test_add),
        cmocka_unit_test(test_sub),
        cmocka_unit_test(test_div),
        cmocka_unit_test(test_mul),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}

